<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController,
    think\Cache,
    app\common\library\Lottery;

class IndexController extends HomeBaseController
{
    public function index()
    {
        return $this->fetch(':index');
    }
    public function test(){
        $people = array("Bill"=>'a', "Steve"=>'b', "Mark"=>'c', "David"=>'d');
        echo "键的当前位置是：" . key($people);
    }
    public function getResult()
    {
        $lottery=new Lottery(1);
        $re=$lottery->getResult();
        if($re === true){
            Cache::inc('win');
//            return '<br>中奖';
        }elseif($re === false){
            Cache::inc('lose');
//            return '<br>未中奖';
        }
    }
    public function TestLottery()
    {
        Cache::rm('win');
        Cache::rm('lose');
//        Cache::rm('game_1');
        for($i=1;$i<=100;$i++){
            $this->getResult();
        }
        return '中奖人数：'.Cache::get('win').'<br>'.'未中奖人数：0'.Cache::get('lose');
    }
}
